package dry.example.parse2;


import com.github.javaparser.StaticJavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.comments.Comment;

import java.io.File;
import java.util.List;
import java.util.stream.Collectors;

public class CommentRemover {

    private static final String FILE_PATH = "D:\\zhouchun\\code_self\\spring_cloud_simple\\src\\main\\java\\dry\\example\\parse2\\ReversePolishNotation.java";

    public static void main(String[] args) throws Exception {
        CompilationUnit cu = StaticJavaParser.parse(new File(FILE_PATH));

        List<Comment> comments = cu.getAllContainedComments();
        //List<Comment> unwantedComments = comments.stream().filter(p -> p.getCommentedNode().isEmpty() || p.isLineComment()).collect(Collectors.toList());
        //List<Comment> unwantedComments = comments.stream().filter(p -> p.isLineComment()).collect(Collectors.toList());
        //unwantedComments.forEach(Node::remove);

        //System.out.println(cu);



        for(Comment p :comments){
            System.out.println("start");
            System.out.println(p.getContent());


            System.out.println(p.isLineComment());
            System.out.println(p.isBlockComment());
            System.out.println(p.isJavadocComment());




            System.out.println("end");
            System.out.println("------");
        }





    }

}

